package main

import (
	"fmt"
	"os"
)

// Author : CSR丶WARRIOR
// Time ： 2020/10/21  20:21
// TOOLS : GoLand
// FILENAME : appendData.go
// STATEMENT: 向已存在文件中追加数据

func main() {
	writeData()
}

func writeData() {
	var path string = "D:\\WARRIOR\\Go\\go\\src\\golang_suse\\advanceModule\\IO\\textFileHandle\\testWrite.txt"
	file, err := os.OpenFile(path, os.O_RDWR, 6)
	if err != nil {
		fmt.Println(err)
	}
	for i := 0; i < 10; i++ {
		num, _ := file.Seek(0, os.SEEK_END)
		var content = "hahaha\n"
		_, err1 := file.WriteAt([]byte(content), num)
		if err1 != nil {
			fmt.Println(err1)
		}
	}

	defer file.Close()
}
